package com.bytech.common.biz.enums.comment;

import java.util.HashMap;
import java.util.Map;

import com.bytech.common.utils.StringUtils;
import lombok.Getter;

/**
 * @Author zhao
 * @Create 2021/8/5 16:38
 */
@Getter
public enum CommentStatusEnum {

    UNKNOWN("unknown", "未知"),
    HIDDEN("hidden", "已隐藏"),
    DELETED("deleted", "已删除"),
    NORMAL("normal", "正常"),
    ;

    private final String value;
    private final String desc;

    CommentStatusEnum(String value, String desc) {
        this.value = value;
        this.desc = desc;
    }

    private static final Map<String, CommentStatusEnum> map = new HashMap<>(CommentStatusEnum.values().length);

    static {
        for (CommentStatusEnum e : CommentStatusEnum.values()) {
            map.put(e.value, e);
        }
    }

    public static CommentStatusEnum of(String state) {
        if (StringUtils.isBlank(state)) {
            return UNKNOWN;
        }
        return map.get(state) == null ? UNKNOWN : map.get(state);
    }

}
